<template>
<section @click="clickCurrent('current')" @mousedown="clickCurrent('dragging')">
    <div :class="['custorm--modelbox', 'graphichotspots-show', (custormCurrent == custormIndex)?'drag active':'drag']">
        <div v-if="custormItemData.params.isshow == '2'" class="noshow" v-bind:style="{'background-image':`url(${getPath('noshow.png')})`}"></div>
        <div>
            <div class="es-picture" style="overflow: hidden;" v-bind:style="{'background':`${custormItemData.style.bgcolor}`}">
                <div class="hotspots-list" :style="{'width': `${imgX(item)}px`, 'height': `${imgY(item)}px`, 'left': `${imgL(item)}px`, 'top': `${imgT(item)}px`}" v-for="(item, index) in Array.isArray(custormItemData.data) ? custormItemData.data : []" :key="index">
                  <p class="pos-center ellipsis">{{`${item.link.title || ''}${item.link.path || item.link.app_id || item.link}`}}</p>
                </div>
                <img :src="getPath(custormItemData.params.thumb && custormItemData.params.thumb.file_path ? custormItemData.params.thumb.file_path : 'default_banner.png')" draggable="false">
            </div>
            <div class="btn-edit-del" @click="delCurrent"><span class="btn-del iconfont icon icon-close"></span></div>
        </div>
    </div>
</section>
</template>

<script>
import defaultConfig from './utils/showConfig'
const fixed = 373
export default {
  mixins: [defaultConfig.mixins],
  props: {
    defaultConfig: {
      type: Object,
      default: function() {
        return defaultConfig
      }
    }
  },
  computed: {
    scale() {
      return fixed / this.custormItemData.params.fixed
    },
    imgX() {
      return function(item) {
        const { width } = item
        return width * this.scale
      }
    },
    imgY() {
      return function(item) {
        const { width, height } = item
        return this.imgX(item) * (height / width)
      }
    },
    imgL() {
      return function(item) {
        const { pos_x } = item
        return pos_x * this.scale
      }
    },
    imgT() {
      return function(item) {
        const { pos_y } = item
        return pos_y * this.scale
      }
    }
  },
  methods: {

  }
}
</script>

<style lang="scss" scoped>
.custorm--modelbox.graphichotspots-show {
    .es-picture {
      position: relative;
      img {
        width: 100%;
        display: block;
      }
      .hotspots-list{
        position: absolute;
        border: 2px dashed rgba(214, 214, 214, 0.4);
        color: #409eff;
        font-size: 12px;
        background: rgba(235, 239, 243, 0.2);
        .pos-center{
          width: 80%;
          text-align: center;
        }
      }
    }
}
</style>
